package com.coldchain.cys.api;


import com.coldchain.authclient.annotation.CheckUserToken;
import com.coldchain.common.resource.annotation.Resource;
import com.coldchain.cys.entity.CysChild;
import com.coldchain.cys.mapping.MappingUtils;
import com.coldchain.cys.service.ICysService;
import com.fangliai.core.entitiy.SystemModelEnum;
import com.function.common.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 设置管理的页面
 * @author TianPeng
 *
 * 2018年9月5日
 */
@Controller
@CheckUserToken
@Resource(groupName="设置", sysMode = SystemModelEnum.USER)
@ApiIgnore
public class SetupController {
	
	@Autowired
	private ICysService cysService ;
	
	@Resource(menuName="帮助中心")
	@RequestMapping(value=MappingUtils.SHOW_HELP_CENTER_PAGE)
	public ModelAndView showHelpCenterPage(){
		ModelAndView m = new ModelAndView(MappingUtils.SHOW_HELP_CENTER_PAGE);
		CysChild cysChild = cysService.getCurrentLogin() ;
		m.addObject("current", cysChild == null ? new CysChild() : cysChild) ;
		return m ;
	}

	@Resource(menuName="修改密码")
	@RequestMapping(value=MappingUtils.SHOW_EDIT_PASS_PAGE)
	public ModelAndView showEditPassPage(){
		ModelAndView m = new ModelAndView(MappingUtils.SHOW_EDIT_PASS_PAGE);
		CysChild cysChild = cysService.getCurrentLogin() ;
		m.addObject("current", cysChild == null ? new CysChild() : cysChild) ;
		return m ;
	}
	
	@ResponseBody
	@RequestMapping(value=MappingUtils.DO_EDIT_PASS,method={RequestMethod.POST})
	public RestResponse doEditPass(String originalPass,String newPass,String newPass2){
		return cysService.doEditPass(originalPass,newPass,newPass2) ;
	}
}
